<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%> 
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>  
<%
	String path = request.getContextPath();
%>	
<!doctype html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="copyright" content=""/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>  
	<title>设置-部门管理</title>
	<link href="../favicon.ico" rel="shortcut icon">
	<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
	<link href="${pageContext.request.contextPath}/css/system/public.css" />
	<link href="${pageContext.request.contextPath}/css/system/set.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath}/css/system/app.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath}/css/system/content.css" rel="stylesheet">
     <!--提示框 -->
    <!-- <link rel="stylesheet" type="text/css" href="../sys/set/css/alert.css" /> -->
    <!--  -->
	<link href="${pageContext.request.contextPath}/css/system/alert.css" rel="stylesheet">
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/system/app.js"></script>
	<link href="<%=path%>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
	<link href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
	<link href="<%=path%>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
	<link href="<%=path%>/hplus/css/animate.min.css" rel="stylesheet">
	<link href="<%=path%>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
	
<style type="text/css">
.m_xpages .mian a.pageDisable {
    color: #bdbdbd;
}

.con-top{
font-size:14px;
}

.content{
    max-height: 1160px;
}
.s_ppp{
    transform: rotate(-90deg) rotateY(180deg);
    width: 200px;
    position: absolute;
    z-index: 99999;
    background: #fff;
    background-size: 100% 100%;
    padding: 0;
    display: none;
    left: 90px;
    top: -3px;
}
.delete_md_detail{
    float: left;
    /* width: 100%; */
}
 .con-top>a>span:hover{
text-decoration: underline;
} 
/* zhiwen */
 a:hover{
 text-decoration:underline;
 } 
</style>
</head>
<body class="gray-bg">
  <div class="wrapper wrapper-content animated fadeInRight">
 <!-- 浮窗改为公用框 -->
    <div id="hide_dp" style="width:100%;height: 100%;z-index: 9999;background: rgba(0,0,0,.3);
              position: fixed;display: none;">
	<div id="hide_dp2" style="background: #fff;position: fixed;z-index:9999; left: 35%;
                 top: 20%;width: 400px; border-radius: 3px;border-top: 4px solid #03a9f4;
                 padding: 30px 2%;line-height: 30px;display: none;">
                  <div ><span><img id = "i_close" style="cursor:pointer;float: right;" src="${pageContext.request.contextPath}/images/system/close.png" /></span>
                      <h4 style="text-align: center;font-size: 20px;margin-bottom: 30px;color: #333;background: #fff;">部门详情</h4>
                  </div>
    	<div style="" class="fix">
         <div style="color: #9CA6B8;margin-left: 50px;font-size: 16px;float: left;" class="labels">部门名称:</div>
         <div class="info" > <span style="margin-left: 30px;color: #9CA6B8;font-size: 16px;" id= "hide_dpId"  ></span></div>
        </div>
        <div style="" class="fix">
         <div style="color: #9CA6B8;margin-left: 50px;font-size: 16px;float: left;" class="labels">部门主管:</div>
         <div class="info" > <span style="margin-left: 30px;color: #9CA6B8;font-size: 16px;" id= "hide_dpLeader"  ></span></div>
         </div>
        <div style="" class="fix">
        <div style="color: #9CA6B8;margin-left: 50px;font-size: 16px;float: left;" class="labels">部门描述:</div>
        <div class="info"> <span style="margin-left: 30px;color: #9CA6B8;font-size: 16px;" id= "hide_dpDcript_"  ></span></div>
        </div>
        <div style="" class="fix">
        <div style="color: #9CA6B8;margin-left: 50px;font-size: 16px;float: left;" class="labels">创建人:</div>
        <div class="info"> <span style="margin-left: 50px;color: #9CA6B8;font-size: 16px;" id= "hide_dpUser"  ></span></div>
        </div>
        <div style="" class="fix">
        <div style="color: #9CA6B8;margin-left: 50px;font-size: 16px;float: left;" class="labels">创建时间:</div>
        <div class="info" > <span style="margin-left: 30px;color: #9CA6B8;font-size: 16px;" id= "hide_dpCreateTime" ></span></div>
        </div>
        </div>
        </div>
    <div class="container-fluid" style="background: #fff;">
	  <div class="row" style="display: flex;background: #fff;" style="height:auto">
		<div class="col-md-12" >
			<div class="col-md-12 content orgchart" style="margin-left: -25px;
	               margin-top: 35px;background: #fff;flex:4;left:40px;" >
				<table>
					<tr id="tr1_1" data-num="1" >
						<td colspan="4" >
							<div class="box flex-direction width" id="mouse_move">
							<div id = "OneDataId" style="display:none"></div>
							<div id = "OneDataPid" style="display:none"></div>
							<div id = "Pid_Rigth" style="display:none"></div>
								<div class="box item s_item" style="display:block;" onclick="showInfo()">
									<div style="cursor: pointer;" onclick="showOneFloatingBox()" class="con-top" >
										<a style="text-decoration: none;color: white;"  ><span style="color: #fff;" id = "Dpname">												
										</span></a>
									</div>
									<div class="item-bottom con-bottom">
										<p class="con-left"><a href="javascript:;"  id="selectonedate" class="fL_edit" >编辑</a></p>
										<div class="con-middle" ><shiro:hasPermission name="sys_dept_member_button"><a href="javascript:addMem();"  id="" class="fL_add">添加成员</a></shiro:hasPermission></div> 
										<div class="con-right"><a href="javascript:void(0);" onclick="nodes.addNode('1')">添加子部门</a></div>
									</div>
	<!-- 										<div class="popDiv s_ppp"> -->
	<!-- 		                                    <div class="fix"> -->
	<!-- 		                                        <div class="labels">部门名称</div> -->
	<!-- 		                                        <div id="frist_dename" class="info"></div> -->
	<!-- 		                                    </div> -->
	<!-- 		                                    <div class="fix"> -->
	<!-- 		                                        <div class="labels">部门主管</div> -->
	<!-- 		                                        <div id= "frist_deleader" class="info"></div> -->
	<!-- 		                                    </div> -->
	<!-- 		                                    <div class="fix"> -->
	<!-- 		                                        <div class="labels">部门描述</div> -->
	<!-- 		                                        <div id= "frist_dedep" class="info"></div> -->
	<!-- 		                                    </div> -->
	<!-- 		                                    <div class="fix"> -->
	<!-- 		                                        <div class="labels">创建人</div> -->
	<!-- 		                                        <div id= "frist_decreater" class="info"></div> -->
	<!-- 		                                    </div> -->
	<!-- 		                                    <div class="fix"> -->
	<!-- 		                                        <div class="labels">创建时间</div> -->
	<!-- 		                                        <div id="first_detime" class="info"></div> -->
	<!-- 		                                    </div> -->
	<!-- 		                                </div> -->
								</div>
							</div>
						</td>
					</tr>
					<tr class="lines" id="tr2_1">
					</tr>
					<tr class="lines" id="tr3_1">	
					</tr>
					<tr class="nodes" id="tr4_1">	
					</tr>
				</table>
			</div>
		</div>
	</div>
	  </div>
   </div>
    
    <!-- 编辑信息弹框 -->
    <div class="s_popup" id="s_popup_edit">
        <div class="issue s_compile" id="issue_edit">
            <span><img src="${pageContext.request.contextPath}/images/system/close.png" /></span>
            <h4 id="h4">编辑信息</h4>
            <ul class="fix">
                <li id="de_name_li" style="display:none">
                    <span><i>*</i>部门名称</span>
                    <div id = "save_Did" style="display: none;"></div>
                    <div id = "save_Pid" style="display: none;"></div>
                    <div class="s_input_box">
                        <input type="text" id="de_name_edit" placeholder="部门名称" />
                    </div>
                </li>
                <li  style="display:none" id="de_des_li">
                    <span>部门描述</span>
                    <div class="s_input_box">
                        <textarea placeholder="最多不超过20个字" id="de_des_edit"></textarea>
                    </div>
                </li>    
            </ul>
            <ol class="fix">
                <!-- <div id="warning_word_bj" style="color:red;text-align:center;"></div> -->
                <li><a style="width: 100px;height: 40px;display: block;" href="javascript:;" class="s_cancel">取消</a></li>
                <li><a style="width: 100px;height: 40px;display: block;" href="javascript:;" id="s_confirm">确定</a></li>
            </ol>
        </div>
    </div>
    
        <!-- 提示框 -->
        <div class="s_popup_delect2">
        <div class="s_consum">
            <p id="dialog_title"><img src="${pageContext.request.contextPath}/images/system/s_tick.png" > </p >
        </div>
        </div>
        <!--  -->
    
   <!-- 部门删除弹框 -->
        <div class="s_popup_box s_popup_delect">
        <div class="s_popup_detailed issue_delect">
        <div style="display: none;" id = "save_dp_id" ></div>
            <span><img src="${pageContext.request.contextPath}/images/system/close.png" id ="img_cancel" /></span>
            <h4><img src="${pageContext.request.contextPath}/images/system/warning.png" /> 删除提示</h4>
            <h5>确定要删除此部门吗？</h5>
            <p><a href="javascript:;" class="s_cancel_del" >取消</a> <a href="javascript:;" class="s_confirm_del" >确定</a></p>
        </div>
      </div>
    
    <!-- 账号列表 -->
    <div class="s_popups">
        <div class="s_number_list" style="height: 600px;overflow-y:auto;">
            <span><img src="${pageContext.request.contextPath}/images/system/close.png" /></span>
            <h4>账号列表</h4>
            <ul class="s_role_condition s_xk_title fix">    
                <li>关键字<input id="keyword" type="text" placeholder="输入姓名、电话、职位"/></li>
                <li>部门
                    <div class="select" style="width:76%;">
                      <span id="s" style="width:100%;text-align:left;float:left;">全部</span>
                      <div class="selectBox">
                        <ul class="fix"id="department_name">
<!--                           <li>管理员</li>
                          <li>管理员11</li>
                          <li>管理员22</li> -->
                          <li>全部</li>
                        </ul>
                      </div>
                      <i class="dropImg"><img src="${pageContext.request.contextPath}/images/system/dropDown.png"/></i>
                    </div>                        
                </li>
                <li class="s_search_btn" style="float:left" id='searchA'><i><img src="${pageContext.request.contextPath}/images/system/icon_search.png" /></i></li>
            </ul>
            <table >
                <thead>
                    <tr>
                      <th></th>
                      <th>姓名</th>
                      <th>电话</th>
                      <th>邮箱</th>
                      <th>职位</th>
                      <th>角色</th>
                    </tr>
                </thead>
                <tbody id='userList'>
                   <!--  <tr>
                      <td><img src="${pageContext.request.contextPath}/images/system/s_check_no.png" class="s_fk_pic1"/></td>
                      <td>刘璐</td>
                      <td>18392817263</td>
                      <td>cutelili8023@163.com</td>
                      <td>总经理</td>
                      <td>超级管理员</td>
                    </tr> -->
                </tbody>
            </table>
            <div class="m_xpages" style="height:1px;">
                <div class="mian">
                    <span>显示行数</span>
                    <select><option>5</option><option>20</option><option>30</option></select>
                    <span>共0条</span>
                    <span>1/1页</span>
                    <a href="javascript:;" class="prev">上一页</a>
                    <a href="javascript:;" class="next">下一页</a>
                    <span>前往</span>
                    <input type="text" value="1" class="text">
                    <span>页</span>
                </div>
            </div>
           <!--  <div id="warning_word_zc" style="color:red;text-align:center;"></div> -->
            <ol class="fix">
                <li><a href="javascript:;" class="s_cancels" style="width: 100px;height: 40px;display: block;">取消</a></li>
                <li><a href="javascript:;" id="s_confirms" style="width: 100px;height: 40px;display: block;">确定</a></li>
            </ol>
        </div>
    </div>


	<!-- 显示信息部分 -->
<!-- 	<div class="popDiv"> -->
<!-- 	      <div class="fix"> -->
<!-- 	           <div class="labels">部门名称</div> -->
<!-- 	           <div class="info">北部大区</div> -->
<!-- 	      </div> -->
<!-- 	      <div class="fix"> -->
<!-- 	           <div class="labels">部门主管</div> -->
<!-- 	           <div class="info">孙文生</div> -->
<!-- 	      </div> -->
<!-- 	      <div class="fix"> -->
<!-- 	           <div class="labels">部门描述</div> -->
<!-- 	           <div class="info">是一个符合要求的部门，这个部门很好很好。</div> -->
<!-- 	      </div> -->
<!-- 	      <div class="fix"> -->
<!-- 	          <div class="labels">创建人</div> -->
<!-- 	          <div class="info">孙文生</div> -->
<!-- 	      </div> -->
<!-- 	      <div class="fix"> -->
<!-- 	          <div class="labels">创建时间</div> -->
<!-- 	          <div class="info">2017-05-07</div> -->
<!-- 	      </div> -->
<!--      </div> -->

    <!-- 添加成员弹框 -->
    <div class="s_popup" id="s_popup_add">
        <div class="issue s_compile" id="issue_add">
            <span><img src="${pageContext.request.contextPath}/images/system/close.png" /></span>
            <h4 id="h4">添加成员</h4>
            <ul class="fix">   
                <li style="display:none" id="add_manger_li">
                    <span>部门主管</span>
                    <div class="s_input_box" style="border:1px solid #ddd">
                        <!-- <input type="text" id="de_manager_name_edit"/> -->
                        <ul id="de_manager_name_edit">                       
                        </ul>
                    </div>
                    <a href="javascript:;" class="s_search_box" id="s_search_leader">查找</a>
                <li  style="display:none" id="de_member_li">
                    <span>部门成员</span>
                    <div class="s_input_box" style="border:1px solid #ddd ;height:100px">
                        <!-- <textarea placeholder="" id="de_member_edit"></textarea> -->
                        <ul id="de_member_edit">                       
                        </ul>
                    </div>
                    <a href="javascript:;" class="s_search_box" id="s_search_member">选择成员</a>
                </li>
            </ul>
            <ol class="fix">
                <!-- <div id="warning_word_bj" style="color:red;text-align:center;"></div> -->
                <li><a href="javascript:;" class="s_cancel_add" style="width: 100px;height: 40px;display: block;">取消</a></li>
                <li><a href="javascript:;" id="s_confirm_add" style="width: 100px;height: 40px;display: block;">确定</a></li>
            </ol>
        </div>
        
       
    </div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/system/addUser.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/system/addLMember.js?random=11"></script>	
<script type="text/javascript" src="${pageContext.request.contextPath}/js/system/exit.js"></script>

<script>

$('#img_cancel,.s_cancel_del').click(function(){
	$('.s_popup_box').removeClass("show");
	$('.s_popup_box').addClass("hide");
	$('.s_popup_detailed').removeClass("show");
	$('.s_popup_detailed').addClass("hide");
});

$('.s_confirm_del').click(function(){
	
	if (($('#save_dp_id').text())!=null&&($('#save_dp_id').text())!="") {
		var id = $('#save_dp_id').text().trim();
		
		nodes.removeNode(id);
		$('#save_dp_id').text("");
		$('.s_popup_box').removeClass("show");
		$('.s_popup_box').addClass("hide");
		$('.s_popup_detailed').removeClass("show");
		$('.s_popup_detailed').addClass("hide");
	}
	
});



$('#de_des_edit').on('input propertychange change',function(){
	$(this).attr("maxlength",50);
	if (($(this).val().length)>=50) {
	}
	
});

$('input').on('input propertychange change',function(){
	$(this).attr("maxlength","20");
	if (($(this).val().length)>=20) {
		//alert("输入字符长度超出规定界限");
	}
	
});

$(function(){
	$('.s_item').on('mouseenter',function(){
	    $(this).find('.s_ppp').stop().fadeIn();
	});
	$('.s_item').on('mouseleave',function(){
	    $(this).find('.s_ppp').stop().fadeOut();
	});
});

/* 提示框 */
function showDialog(title){
	
	$('#dialog_title').html('<img src="${pageContext.request.contextPath}/images/system/s_tick.png" >'+title+''); 
	$('.s_popup_delect2,.s_consum').show().delay(1000).fadeOut();
}
/*  */

$(function(){
	$(document).on("click",".selectBox ul li",function(){
        //$('.selectBox ul li').on('click',function(){
          var text = $(this).text();
          console.log(text);
          $(this).parents('.select').find('span').text(text);
        });          
        
        $('.select').on('click',function(){
          $(this).toggleClass('selectState');
          if(!$(this).hasClass('selectState')){
            $('.select').removeClass('selectState');
            $(this).next().find('img').attr('src','images/dropDown.png');
          }else{
            $(this).next().find('img').attr('src','images/dropUp.png');
          }
        });
      
    $('.box .item').on('mouseover',function(){
        $(this).find('#fdept').show();
        console.log("login");
    });
    $('.box .item').on('mouseleave',function(){
        $(this).find('#fdept').hide();
        console.log("exit");
    });                     
    $('.s_cancel').click(function(){
        $('.s_popup').hide();
        $('.issue').hide();
    });
    $('.s_cancels').click(function(){
        $('.s_popups').hide();
        $('.s_number_list').hide();
		$('#s_popup_add').show();
        $('#issue_add').show();
    });
    $('.s_popup .issue > span').click(function(){
        $('.s_popup').hide();
        $('.issue').hide();
    });
     $('.s_popups .s_number_list > span').click(function(){
        $('.s_popups').hide();
        $('.s_number_list').hide();
		$('#s_popup_add').show();
        $('#issue_add').show();
    });
/*     $('.s_search_box').click(function(){
        $('.s_popup').hide();
        $('.issue').hide();
        $('.s_popups').show();
        $('.s_number_list').show();
    }); */
    
    $('.s_cancel_add').click(function(){
        $('.s_popup').hide();
        $('.issue').hide();
    });
    /* 编辑部门信息 */
	/*$(document).on('click','.fL_edit',function(){
		$('#h4').text('部门信息变更');
		//名称和描述显示
		$('#de_name_li').attr('style','display:blcok');
		$('#de_des_li').attr('style','display:blcok');
		$('#add_manger_li').attr('style','display:none');
		$('#de_member_li').attr('style','display:none');
		
		var valuegg = $(".fL_edit").text();
		alert(valuegg);
		
		$('.s_popup').show();
        $('.issue').show();
	});*/
    
	
	/* 鼠标移入移除显示 */
	$('#mouse_move').hover(function(){
		
	},function(){
		 
	});
	
})

</script>


    
    
    <!--   ZHIWEN -->
    <script type="text/javascript">
    /* 第一条数据弹出 */
        	  
    function showOneFloatingBox(){
    	 //第一条原始数据获取
	    $.ajax({
 		  url: "${pageContext.request.contextPath}/api/department/getOneData",

 		  type: "post",
 		  
 		  async: false,

 		  data:{},

 		  dataType: "json",

 		  timeout: 1000,

 		  error: function(){},

 		  success: function(data){
 			  var returnData = eval(data);
 			  if (returnData.error_code==0) {
 				 
				 var name = returnData.name;
 				 var Dpid = returnData.id;
 				 var pid = returnData.bak1;

 				  $("#hide_dpId").text("");
 				  $("#hide_dpDcript_").text("");
 				  $("#hide_dpLeader").text("");
 				  $("#hide_dpCreateTime").text("");
 				  $("#hide_dpUser").text("");
 				
 				   if ((returnData.name)!=null&&(returnData.name)!="") {
					  $("#hide_dpId").text(returnData.name);
				}
				  if ((returnData.description)!=null&&(returnData.description)!="") {
					  $("#hide_dpDcript_").text(returnData.description);
				}
				
				 if ((returnData.bak2)!=null&&(returnData.bak2)!="") {
					 $("#hide_dpLeader").text(returnData.bak2);
				}
				
				 if ((returnData.bak4)!=null&&(returnData.bak4)!="") {
					
					 $("#hide_dpCreateTime").text(returnData.bak4);
				}
				 if ((returnData.bak3)!=null&&(returnData.bak3)!="") {
					 $("#hide_dpUser").text(returnData.bak3);
				}
				  
				    $('#hide_dp').removeClass("hide");
					$('#hide_dp').addClass("show");
					$('#hide_dp2').removeClass("hide");
					$('#hide_dp2').addClass("show");
 				 
			} else {
                //alert(returndata.message);
				showDialog(returndata.message);
			}
 		   }
 		  }); 

/*  */
    }
    
    
      $(function(){
    	  
    	   //第一条原始数据获取
    	    $.ajax({
     		  url: "${pageContext.request.contextPath}/api/department/getOneData",

     		  type: "post",
     		  
     		  async: false,

     		  data:{},

     		  dataType: "json",

     		  timeout: 1000,

     		  error: function(){},

     		  success: function(data){
     			  var returnData = eval(data);
     			  if (returnData.error_code==0) {
     				 
					 var name = returnData.name;
     				 var Dpid = returnData.id;
     				 var pid = returnData.bak1;
     				 //alert(name+"显现"+Dpid)
     				 $('#Dpname').text(name);
     				 $('#OneDataId').text(Dpid);
     				 $('#OneDataPid').text(pid);
     				 
     				 //第一条数据浮框显示
//      				 if ((returnData.name)!=null&&(returnData.name)!="") {
// 						$('#frist_dename').text(returnData.name);
// 					    }
//      				 if ((returnData.bak2)!=null&&(returnData.bak2)!="") {
//  						$('#frist_deleader').text(returnData.bak2);
//  					}
//      				 if ((returnData.description)!=null&&(returnData.description)!="") {
//  						$('#frist_dedep').text(returnData.description);
//  					}
//      				 if ((returnData.bak3)!=null&&(returnData.bak3)!="") {
//  						$('#frist_decreater').text(returnData.bak3);
//  					}
//      				 if ((returnData.createTime)!=null&&(returnData.createTime)!="") {
//  						$('#first_detime').text(returnData.createTime);
//  					}
     				
     				 
				} else {
                    //alert(returndata.message);
					showDialog(returndata.message);
				}
     		   }
     		  }); 
    	   
    	    $('#selectonedate').click(function(){
    			   //第一条原始数据编辑（回显在前）
    	  	    
    	  	    $.ajax({
    	   		  url: "${pageContext.request.contextPath}/api/department/getOneData",

    	   		  type: "post",
    	   		  
    	   		  async: false,

    	   		  data:{},

    	   		  dataType: "json",

    	   		  timeout: 1000,

    	   		  error: function(){},

    	   		  success: function(data){
    	   			  var returnData = eval(data);
    	   			 	 if (returnData.error_code==0) {
    	   				 
    						     var name = returnData.name;
    	   				 var description = returnData.description;
    	   				 $('#de_name_edit').val(name);
    	   				 $('#de_des_edit').val(description);
    	   				 $('#save_Pid').text(1);
    	       				  $('#h4').text('编辑部门');
    	       					//名称和描述显示
    	       					$('#de_name_li').attr('style','display:blcok');
    	       					$('#de_des_li').attr('style','display:blcok');
    	       					$('#add_manger_li').attr('style','display:none');
    	       					$('#de_member_li').attr('style','display:none');
    	       					
    	       					
    	       					
    	       					$('#s_popup_edit').show();
    	       			        $('#issue_edit').show();
    	   				
    			   				} else {
    			                       //alert(returndata.message);
    			                       showDialog(returndata.message);
    			   				}
    	   		   }
    	   		  }); 
    		   })
    	   
    	   //部门管理数据结构回显
    	    $.ajax({
     		  url: "${pageContext.request.contextPath}/api/department/show",

     		  type: "post",
     		  
     		  async: false,

     		  data:{},

     		  cache:false,
     		  
     		  dataType: "json",

     		  timeout: 1000,

     		  error: function(){},

     		  success: function(data){
     			 
     			  //数据回显
     			  var returndata = eval(data);
     			  
     			 var first = returndata[0].id;  
     			 
     			 for (var i = 0; i < returndata.length; i++) {
					var ID = returndata[i].id;
					for (var j = 0; j < returndata.length; j++) {
						var PID = returndata[j].parentDeptId;
						if (ID==PID) {
							
								var pid = returndata[j].bak1;
								
// 								var left=	pid.substring(0,pid.length-2);
// 								var right = pid.substring(pid.length-1,pid.length)
								/* 换种分割 */
								var pidar = new Array();
								pidar = pid.split("_");
								var pidlength = pidar.length;
							
								var right =pidar[pidlength-1];
								
								var left = pid.substring(0,(pid.length-right.length-1));
								
								/*  */
								$('#Pid_Rigth').text(right);
								nodes.addNode(left);


					         	var no_id = '#node_'+nodes.pid;
								$(no_id).text(returndata[j].bak1);
		     					//alert($(no_id).text()+"ds");
			     				var name_id = '#Id_'+nodes.pid;
			     				//alert(d_id);
			     				$(name_id).text(returndata[j].name);
			     				//alert($(name_id).text());
			     				var DI_id = '#DId_'+nodes.pid;
			     				 $(DI_id).text(returndata[j].id);
			     				

						}
					}
				}
     			  
     			
     			
     			 
     			 
//      			 for (var m = 1; m < returndata.length; m++) {
     				 
//      				for (var int = 1; int < returndata.length; int++) {
// 	     				var pid = returndata[int].bak1;
	     				
// 	     				if (pid.split("_").length==(m+1)) {
							
// 						var left=	pid.substring(0,pid.length-2);
// 						var right = pid.substring(pid.length-1,pid.length)
							
						   
// 						    nodes.text = right-1;
// 						    nodes.pid = left+'_'+$('#tr1_'+left).data('num');
						    
// 	     					$('#tr4_'+left).append(nodes.node);
// 	     					nodes.addLine(left);
	     					
// 		     				var d_id = '#Id_'+nodes.pid;
// 		     				$(d_id).text(returndata[int].name);
						
// 		     			    $('#tr1_'+left).data('num',parseInt(nodes.text)+1);
// 		     				if(nodes.counttree(nodes.pid) == 1){
// 		     				    $('#item_' + nodes.pid).css('background','#03a9f4');
// 		     				}else if(nodes.counttree(nodes.pid) == 2){
// 		     					$('#item_' + nodes.pid).css('background','#fd7167');
// 		     				}
// 						}
//  	 				}
//      			 }
     			 
     				
				
     			  
      		    }
     		  }); 
    	  
		
          //update部门

     	$('#s_confirm').click(function(){
    	  var Name = 	$('#de_name_edit').val();
    	  var Description = $('#de_des_edit').val();   	 
    	  var D_id = $('#save_Did').text();  
    	  var Pid = $('#save_Pid').text(); 
    	  if (Pid==1||Pid =="1") {
    		 D_id  = $('#OneDataId').text();
    		  
    		 console.log(D_id);
		}
    	  var str = 0;
    	  var arraylist = new Array();
    	  arraylist = Name.split("");
    	  var strrr = " ！!,，。.；;/@、|：#$%^&*(){}|‘’<>:''《》：“？{}”" +"\""+""+"\""+"\\";
    	
    	  for (var s = 0; s < arraylist.length; s++) {
    		  
    		 if ((strrr.indexOf(arraylist[s]))>0) {
				
			} else {
               str =1;
			}
		}
    	  
    	  if (str==1) {
    		str=0;
    	  $.ajax({
     		  url: "${pageContext.request.contextPath}/api/department/update",

     		  type: "post",
     		  
     		  async: true,

     		  data:{name:Name,description:Description,id:D_id},

     		  dataType: "json",

     		  timeout: 1000,

     		  error: function(){},

     		  success: function(data){
     			 
     			if (data.error_code==0) {
     				if (data.parentDeptId==0) {
     					var name = data.name;
     					$('#Dpname').text(name);
					} else {
						var p_id = "#Id_"+data.bak1.trim();//部门名称的id
	    				
						$(p_id).text(data.name);	
					}
     				
    													
				}else {
					//alert(data.message);
					showDialog(data.message);
				}
     		   }
     		  }); 
    	  
    	  $('.s_popup').hide();
          $('.issue').hide();
    	
    	  }else {
    		  showDialog("部门名称不能全为特殊字符");
		}
    	  
    	});
    

      }); 
    </script>


<!--      退出 -->

<script type="text/javascript">
var path="${pageContext.request.contextPath}";
var auths = "<%=session.getAttribute("authoritys")%>";
</script>

</body>
</html>
